package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.domain.Leaves;
import com.ruoyi.system.service.LeavesService;
import com.ruoyi.system.mapper.LeavesMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86178
* @description 针对表【sys_leave】的数据库操作Service实现
* @createDate 2024-07-19 11:08:01
*/
@Service
public class LeavesServiceImpl extends ServiceImpl<LeavesMapper, Leaves>
    implements LeavesService{

    @Override
    public Page<Leaves> selectPageVo(Page<Leaves> page, Leaves leaves,String leaveName) {
        Long userId = SecurityUtils.getUserId();
        Page<Leaves> leavesPage = null;
        if(SysUser.isAdmin(userId)){
            leavesPage = baseMapper.selectPageVo(page,leaves);
        }else{
            leavesPage =  baseMapper.selectPageVoByName(page,leaves,leaveName);
        }
        return leavesPage;
    }
}




